package fun.lifepoem.blog.aspect;

import fun.lifepoem.blog.common.annotation.ApiCtlLog;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author Yiwyn
 * @create 2022/10/2 16:55
 */
@Aspect
@Component
@Slf4j
public class ControllerLogAspect {

    @Pointcut("@annotation(fun.lifepoem.blog.common.annotation.ApiCtlLog)")
    public void postCut() {

    }

    @Around("postCut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        String methodName = joinPoint.getSignature().getName();
        Object[] args = joinPoint.getArgs();
        log.info("请求到接口:{},入参:{}", methodName, args);
        return joinPoint.proceed();
    }

}
